﻿@model Sheng.WeixinConstruction.Management.Shell.Models.CurrentUserInfoViewModel

@{
    ViewBag.MainMenu = "System";
    ViewBag.LeftMenu = "CurrentUserInfo";

    ViewBag.Title = "个人信息";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<style type="text/css">
    .divBaseSettingsTitle {
        margin-top: 25px;
        margin-left: 10px;
        margin-right: 10px;
    }

    .divBaseSettings {
        margin-top: 20px;
        margin-left: 10px;
        margin-right: 10px;
    }
</style>

<script language="javascript">

    var _validator;

    $(document).ready(function () {

        $("[keyenter]").keypress(function (e) {
            if (e.keyCode == 13) {
                save();
            }
        });

        _validator = $("#form").validate({
            onfocusout: false,
            onkeyup: false,
            showErrors: showValidationErrors,
            rules: {
                "txtName": "required",
                "txtEmail": {
                    required: true,
                    email: true
                }
            },
            messages: {
                "txtName": "请输入当前密码；",
                "txtEmail": {
                    required: "请再次输入新密码；",
                    email: "请输入正确格式的电子邮件地址；",
                }
            }
        });
    });

    function save() {
        if (_validator.form() == false) {
            return;
        }

        var args = new Object();
        args.Name = $("#txtName").val();
        args.Email = $("#txtEmail").val();
        args.Telphone = $("#txtTelphone").val();

        var loadLayerIndex = layer.load(0, {
            shade: [0.2, '#fff']
        });

        $.ajax({
            url: "/Api/User/Update",
            type: "POST",
            dataType: "json",
            data: JSON.stringify(args),
            success: function (data, status, jqXHR) {
                layer.close(loadLayerIndex);
                if (data.Success) {
                    layerAlert("个人信息已更新。", function () {
                        window.location.reload();
                    });

                } else {
                    layerAlert(data.Message);
                }
            },
            error: function (xmlHttpRequest) {
                layer.close(loadLayerIndex);
                alert("Error: " + xmlHttpRequest.status);
            }
        });
    }

</script>


<div id="divContentTips">
    修改您的个人信息。
</div>

<div class="divBaseSettings">
    <form id="form">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td width="200" height="36" valign="top">姓名：</td>
                <td valign="top"><input name="txtName" type="text" class="input_16" style="width:400px;" id="txtName" maxlength="25" value="@Model.User.Name" keyenter /></td>
            </tr>
            <tr>
                <td height="36" valign="top">电子邮件：</td>
                <td valign="top"><input name="txtEmail" type="text" class="input_16" style="width:400px;" id="txtEmail" maxlength="100" value="@Model.User.Email" keyenter /></td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <div class="font_gray_13" style="width:96%;margin-bottom:10px;">
                        请输入真实有效的电子邮件地址，否则您将无法使用找回密码功能。
                    </div>
                </td>
            </tr>
            <tr>
                <td height="36" valign="top">联系电话：</td>
                <td valign="top"><input name="txtTelphone" type="text" class="input_16" style="width:400px;" id="txtTelphone" maxlength="50" value="@Model.User.Telphone" keyenter /></td>
            </tr>
        </table>
    </form>
</div>

<div style=" margin-top:15px;">
    <input name="btnSave" type="button" class="btn_blue" id="btnStep2Next" value="保存" onclick="save()" />
</div>

